//
//  UNIVoiceView.m
//  CAShapeLayerVoiceView
//
//  Created by 宇宙执政 on 16/11/4.
//  Copyright © 2016年 yujianbinMAC. All rights reserved.
//

#import "UNIVoiceView.h"
#import "UNIVoiceTopView.h"
#import "UNIVoiceBottomView.h"
#import "UIView+UNIViewExtension.h"

@interface UNIVoiceView()


/**
 顶部视图
 */
@property (nonatomic, strong) UNIVoiceTopView *topView;

/**
 底部视图
 */
@property (nonatomic, strong) UNIVoiceBottomView *bottomView;


/**
 线宽
 */
@property (nonatomic, assign) CGFloat lineWith;


/**
 线宽颜色
 */
@property (nonatomic, strong) UIColor *lineColor;


/**
 话筒中间实心颜色
 */
@property (nonatomic, strong) UIColor *solidColor;

@end

@implementation UNIVoiceView

- (instancetype)initWithFrame:(CGRect)frame lineWith:(CGFloat)lWith lineColor:(UIColor *)lColor solidColor:(UIColor *)sColor isSolid:(BOOL)isSolid{
    
    if (self = [super initWithFrame:frame]) {
        _lineWith = lWith;
        _lineColor = lColor;
        _solidColor = sColor;
        
        [self createTopView];
        [self createBottomView];
    }
    return self;
}



- (void)updateVoiceViewWithVolume:(float)volume{
    
    [_topView updateVoiceViewWithVolume:volume];
}

- (void)createTopView{
    _topView = [[UNIVoiceTopView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.height*0.7) lineWith:_lineWith lineColor:_lineColor solidColor:_solidColor];
    
    [self addSubview:_topView];
    
}

- (void)createBottomView{
    _bottomView = [[UNIVoiceBottomView alloc] initWithFrame:CGRectMake(0, self.height*0.71, self.width, self.height*0.3) lineWith:_lineWith lineColor:_lineColor];
    [self addSubview:_bottomView];
}

@end
